From 06163ff5b9ac704606f9a793484939cffe0e2487 Mon Sep 17 00:00:00 2001 From: Adrian Bunk Date: Sun, 15 Nov 2020 16:03:16 +0200 Subject: [PATCH] Fixes and workaround for platforms where Qt uses OpenGL ES --- debian/patches/81_allow_gles_platforms.patch | 46 +++++++++++++++ debian/patches/82_allow_gles_platforms.patch | 61 ++++++++++++++++++++ debian/patches/83_allow_gles_platforms.patch | 29 ++++++++++ debian/patches/series | 3 + 4 files changed, 139 insertions(+) create mode 100644 debian/patches/81_allow_gles_platforms.patch create mode 100644 debian/patches/82_allow_gles_platforms.patch create mode 100644 debian/patches/83_allow_gles_platforms.patch diff --git a/debian/patches/81_allow_gles_platforms.patch b/debian/patches/81_allow_gles_platforms.patch new file mode 100644 index 000000000..938d842c7 --- /dev/null +++ b/debian/patches/81_allow_gles_platforms.patch @@ -0,0 +1,46 @@ +From d7fe3fe9df8c26b5a9ea036511cdb1640f5ae2b4 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Stefan=20Br=C3=BCns?= +Date: Sun, 28 Jun 2020 22:13:32 +0200 +Subject: Replace last glDrawBuffer call with glDrawBuffers(1, ...) + +glDrawBuffer is only available in Desktop OpenGL, while the equivalent +glDrawBuffers is valid also for GLES. + +Just defining glDrawBuffer as an empty macro is obviously not the right +solution, as the call is also required on GLES. This also causes +a compilation failure - GL.h may be included via GLX.h on X11 platforms, +and the glDrawBuffer prototype declaration becomes malformed. +--- + Rendering/ContextOpenGL2/vtkOpenGLContextDevice2DPrivate.h | 3 ++- + ThirdParty/glew/vtk_glew.h.in | 1 - + 2 files changed, 2 insertions(+), 2 deletions(-) + +diff --git a/Rendering/ContextOpenGL2/vtkOpenGLContextDevice2DPrivate.h b/Rendering/ContextOpenGL2/vtkOpenGLContextDevice2DPrivate.h +index 5632547459..ae3bd53f05 100644 +--- a/Rendering/ContextOpenGL2/vtkOpenGLContextDevice2DPrivate.h ++++ b/Rendering/ContextOpenGL2/vtkOpenGLContextDevice2DPrivate.h +@@ -324,7 +324,8 @@ public: + + if (this->SavedDrawBuffer != GL_BACK_LEFT) + { +- glDrawBuffer(this->SavedDrawBuffer); ++ const GLenum bufs[1] = { static_cast(this->SavedDrawBuffer) }; ++ ::glDrawBuffers(1, bufs); + } + + ostate->vtkglClearColor(this->SavedClearColor[0], this->SavedClearColor[1], +diff --git a/ThirdParty/glew/vtk_glew.h.in b/ThirdParty/glew/vtk_glew.h.in +index 6aa8c2ee9e..6afed1d655 100644 +--- a/ThirdParty/glew/vtk_glew.h.in ++++ b/ThirdParty/glew/vtk_glew.h.in +@@ -52,7 +52,6 @@ + + /* some fixes for both ES 2 and 3 */ + #ifdef GL_ES_VERSION_3_0 +-# define glDrawBuffer(arg) + # define GL_BACK_LEFT 0 + # define GL_BACK_RIGHT 0 + # define GL_FRONT_LEFT 0 +-- +2.20.1 + diff --git a/debian/patches/82_allow_gles_platforms.patch b/debian/patches/82_allow_gles_platforms.patch new file mode 100644 index 000000000..ee1d4e340 --- /dev/null +++ b/debian/patches/82_allow_gles_platforms.patch @@ -0,0 +1,61 @@ +From b48706fdff04672bdad6d10afae23afc26b89178 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Stefan=20Br=C3=BCns?= +Date: Tue, 9 Jun 2020 17:11:12 +0200 +Subject: Fix compilation when Qt is built for GLES platforms + +On GLES 2.0/3.0 platforms (more specifically, for Qt5 "opengl es2" builds), +QOpenGLFunctions_3_2_Core does not exist. + +After the last restructuring, from the GL 3.2 Core functions only +glDrawBuffer is used. glDrawBuffer can be trivially replaced with +glDrawBuffers, which is part of OpenGL 2.0 and GLES 3.0, and as an +extension in many GLES 2.0 implementations. +--- + GUISupport/Qt/QVTKRenderWindowAdapter.cxx | 10 +++++----- + 1 file changed, 5 insertions(+), 5 deletions(-) + +diff --git a/GUISupport/Qt/QVTKRenderWindowAdapter.cxx b/GUISupport/Qt/QVTKRenderWindowAdapter.cxx +index 5a66e236df..530cec9b2a 100644 +--- a/GUISupport/Qt/QVTKRenderWindowAdapter.cxx ++++ b/GUISupport/Qt/QVTKRenderWindowAdapter.cxx +@@ -28,9 +28,8 @@ + #include + #include + #include ++#include + #include +-#include +-#include + #include + #include + #include +@@ -334,14 +333,15 @@ public: + { + return false; + } +- QOpenGLFunctions_3_2_Core* f = this->Context->versionFunctions(); ++ QOpenGLExtraFunctions* f = this->Context->extraFunctions(); + if (!f) + { + return false; + } + + f->glBindFramebuffer(GL_DRAW_FRAMEBUFFER, targetId); +- f->glDrawBuffer(targetAttachment); ++ const GLenum bufs[1] = { static_cast(targetAttachment) }; ++ f->glDrawBuffers(1, bufs); + + f->glBindFramebuffer(GL_READ_FRAMEBUFFER, this->FBO->handle()); + f->glReadBuffer( +@@ -436,7 +436,7 @@ public: + { + Q_ASSERT(this->Context && this->FBO); + +- QOpenGLFunctions_3_2_Core* f = this->Context->versionFunctions(); ++ QOpenGLFunctions* f = this->Context->functions(); + if (f) + { + // now clear alpha otherwise we end up blending the rendering with +-- +2.20.1 + diff --git a/debian/patches/83_allow_gles_platforms.patch b/debian/patches/83_allow_gles_platforms.patch new file mode 100644 index 000000000..2e862f542 --- /dev/null +++ b/debian/patches/83_allow_gles_platforms.patch @@ -0,0 +1,29 @@ +From 572a554967c84bba101cf03e3d22c89113407d49 Mon Sep 17 00:00:00 2001 +From: Adrian Bunk +Date: Fri, 11 Dec 2020 10:42:37 +0200 +Subject: HACK: QVTKOpenGLWindow.cxx: Define GL_BACK_{LEFT,RIGHT} for Qt with + OpenGL ES + +--- + GUISupport/Qt/QVTKOpenGLWindow.cxx | 5 +++++ + 1 file changed, 5 insertions(+) + +diff --git a/GUISupport/Qt/QVTKOpenGLWindow.cxx b/GUISupport/Qt/QVTKOpenGLWindow.cxx +index 3bddc19809..79d5c2b653 100644 +--- a/GUISupport/Qt/QVTKOpenGLWindow.cxx ++++ b/GUISupport/Qt/QVTKOpenGLWindow.cxx +@@ -35,6 +35,11 @@ + #include "vtkObjectFactory.h" + #include "vtkOpenGLState.h" + ++#ifndef GL_BACK_LEFT ++#define GL_BACK_LEFT GL_BACK ++#define GL_BACK_RIGHT GL_BACK ++#endif ++ + QVTKOpenGLWindow::QVTKOpenGLWindow(QOpenGLWindow::UpdateBehavior ub, QWindow* p) + : QVTKOpenGLWindow(vtkSmartPointer::New(), nullptr, ub, p) + { +-- +2.20.1 + diff --git a/debian/patches/series b/debian/patches/series index d204b798f..ef2e24cf7 100644 --- a/debian/patches/series +++ b/debian/patches/series @@ -6,4 +6,7 @@ 60_fix_path_perl.patch 70_fix_python_numpy_warning.patch 80_allow_gles_platforms.patch +81_allow_gles_platforms.patch +82_allow_gles_platforms.patch +83_allow_gles_platforms.patch 90_fix_freetype_compilation.patch -- 2.30.2